"""
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    created by lane.chang on '26/10/2024'
    comment: assichat工程相关
"""
import asyncio
from config import Config
from project.core.log import Colors
from project.lib.common import logger
from project.model.micro_service import MicroService
from project.model.basic import Element


class Assichat:

    @staticmethod
    async def send_sms(phone, template_params, ele: Element):
        """ 发送短信
        :param phone:
        :param template_params:
        :param ele:
        :return:
        """
        try:
            logger.info(f'发送[{ele.value}]短信。。。 phone: {phone} template_params: {template_params} template_code: {ele.code}', font_color=Colors.PURPLE.value)
            await MicroService(domain=Config.CARIABOT_DOMAIN).post(url_path='/m/ali_cloud/send_message',
                                                                   phone=phone,
                                                                   template_params=template_params,
                                                                   template_code=ele.code)
        except:
            pass


if __name__ == "__main__":
    asyncio.run(Assichat.send_sms('13520579960', {}, template_code='SMS_465401908'))

